import bus from "@/bus";
import { renderButton } from '@/util';
let data = {
  columns: [{
    title: '门店名称',
    key: 'storeName',
    minWidth: 100
  }, {
    title: '门店联系人',
    key: 'storeContactName',
    align: 'left',
    width: 120
  }, {
    title: '登录手机',
    key: 'storePhone',
    align: 'left',
    width: 120
  }, {
    title: '奖惩返利',
    key: 'rebate',
    align: 'left',
    minWidth: 200,
    renderHeader: (h, p) => {
      return <div><span class="font-red">*</span>奖惩返利</div>
    },
    render: (h, params) => {
      let child = h('InputNumber', {
        style: {width: '80%', marginTop: '3px'},
        props: {
          min: -50000,
          max: 50000,
          value: params.row.rebate,
          precision: 0,
          placeholder: '最大5万，最小-5万',
          'active-change': false
        },
        on: {
          'on-change': (value) => {
            params.row.rebate = value
            bus.$emit('onChangeRebate', {row: params.row, index: params.index, type: 'rebate'})
          }
        }
      })
      let child2 = h('p', {
        class: ['font-red', params.row.rebateHidden ? 'hidden' : '']
      }, '请填写奖惩返利')
      return h('div', [child, child2])
    }
  }, {
    title: '奖惩备注',
    key: 'rewardRemark',
    align: 'left',
    minWidth: 200,
    renderHeader: (h, p) => {
      return <div><span class="font-red">*</span>奖惩备注</div>
    },
    render: (h, params) => {
      let child = h('Input', {
        style: {marginTop: '5px', marginBottom: '3px'},
        props: {
          type: 'textarea',
          rows: 2,
          value: params.row.rewardRemark,
          placeholder: '不超过50字',
          maxlength: 50
        },
        on: {
          'on-blur': (e) => {
            params.row.rewardRemark = e.target.value
            bus.$emit('onChangeRebate', {row: params.row, index: params.index, type: 'remark'})
          }
        }
      })
      let child2 = h('p', {
        class: ['font-red', params.row.remarkHidden ? 'hidden' : '']
      }, '请填写备注')
      return h('div', [child, child2])
    }
  }, {
    title: '操作',
    align: 'left',
    minWidth: 100,
    fixed: 'right',
    render: (h, params) => {
      return (
        <div>
          {renderButton(h, {text: '删除', type: 'primary'}, () => {bus.$emit("onDel", {row: params.row})})}
        </div>
      )
    }
  }],
  data: []
}
export default data
